const mongoose = require('mongoose');

const configSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
    trim: true,
  },
  description: {
    type: String,
    trim: true,
  },
  config: {
    type: mongoose.Schema.Types.Mixed,
    required: true,
  },
  user: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true,
  },
}, { timestamps: true });

// 添加索引以提高查询性能
configSchema.index({ name: 'text', description: 'text' });
configSchema.index({ user: 1 });
configSchema.index({ createdAt: -1 });

const Config = mongoose.model('Config', configSchema);

module.exports = Config;
